home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / unarced / languages / gnuc++ / src / gcc-1.40 / config / tm-amiga.h < prev   
Encoding:
C/C++ Source or Header  |  1995-03-17  |  9.0 KB  |  257 lines

  1. /* Definitions of target machine for GNU compiler.  Amiga 68000/68020 version.
  2.    Copyright (C) 1987, 1988 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include "tm-m68k.h"
  21.  
  22. /* See tm-m68k.h.  7 means 68020 with 68881.  */
  23.  
  24. #ifndef TARGET_DEFAULT
  25. #define TARGET_DEFAULT 0
  26. #endif
  27.  
  28. /* Define __HAVE_FPA__ or __HAVE_68881__ in preprocessor,
  29.    according to the -m flags.
  30.    This will control the use of inline 68881 insns in certain macros.
  31.    Also inform the program which CPU this is for.  */
  32.  
  33. #if TARGET_DEFAULT & 02
  34.  
  35. /* -m68881 is the default */
  36. #define CPP_SPEC \
  37. "%{!msoft-float:-D__HAVE_68881__ }\
  38. %{!ansi:%{m68000:-Dmc68010}%{mc68000:-Dmc68010}%{!mc68000:%{!m68000:-Dmc68020}}}"
  39.  
  40. #else
  41. /* -msoft-float is the default, assume -mc68000 as well */
  42. #define CPP_SPEC \
  43. "%{m68881:-D__HAVE_68881__ }\
  44. %{!ansi:%{m68020:-Dmc68020}%{mc68020:-Dmc68020}%{!mc68020:%{!m68020:-Dmc68010}}}"
  45.  
  46. #endif
  47.  
  48. /* These compiler options take an argument.  We ignore -target for now.  */
  49.  
  50. /* #define WORD_SWITCH_TAKES_ARG(STR)    (!strcmp (STR, "target")) */
  51.  
  52. /* -m68000 requires special flags to the assembler.  */
  53.  
  54. #if TARGET_DEFAULT & 01
  55.  
  56. #define ASM_SPEC \
  57.  "%{m68000:-mc68010}%{mc68000:-mc68010}%{!mc68000:%{!m68000:-mc68020}}"
  58.  
  59. #else
  60.  
  61. #define ASM_SPEC \
  62.  "%{m68020:-mc68020}%{mc68020:-mc68020}%{!mc68020:%{!m68020:-mc68010}}"
  63.  
  64. #endif
  65.  
  66. /* Names to predefine in the preprocessor for this target machine.  */
  67.  
  68. /* amiga/amigados are the new "standard" defines for the Amiga, MCH_AMIGA
  69.  * was used before and is included for compatibility reasons */
  70.  
  71. #define CPP_PREDEFINES "-Dmc68000 -Damiga -Damigados -DMCH_AMIGA -DAMIGA"
  72.  
  73. /* STARTFILE_SPEC to include sun floating point initialization
  74.    This is necessary (tr: Sun does it) for both the m68881 and the fpa
  75.    routines.
  76.    Note that includes knowledge of the default specs for gcc, ie. no
  77.    args translates to the same effect as -m68881
  78.    I'm not sure what would happen below if people gave contradictory
  79.    arguments (eg. -msoft-float -mfpa) */
  80.  
  81. #define STARTFILE_SPEC                    \
  82.   "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}"
  83.  
  84. /* Specify library to handle `-a' basic block profiling.
  85.    Control choice of libm.a (if user says -lm)
  86.    based on fp arith default and options.  */
  87.  
  88. /* for now, no different math libraries exist, there probably *will*
  89.  * be some in the future. */
  90. #define LIB_SPEC "%{g:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
  91.  
  92. /* if debugging, tell the linker to output amiga-hunk symbols *and*
  93.  * a BSD compatible debug hunk */
  94.  
  95. #define LINK_SPEC "%{g:-amiga-debug-hunk} "
  96.  
  97. /* Every structure or union's size must be a multiple of 2 bytes.  */
  98.  
  99. #define STRUCTURE_SIZE_BOUNDARY 16
  100.  
  101. /* This is BSD, so it wants DBX format.  */
  102.  
  103. #define DBX_DEBUGGING_INFO
  104.  
  105. /* This is how to output an assembler line defining a `double' constant.  */
  106.  
  107. #undef ASM_OUTPUT_DOUBLE
  108. #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                    \
  109.   (isinf ((VALUE))                            \
  110.    ? fprintf (FILE, "\t.double 0r%s99e999\n", ((VALUE) > 0 ? "" : "-")) \
  111.    : fprintf (FILE, "\t.double 0r%.20e\n", (VALUE)))
  112.  
  113. /* This is how to output an assembler line defining a `float' constant.  */
  114.  
  115. #undef ASM_OUTPUT_FLOAT
  116. #define ASM_OUTPUT_FLOAT(FILE,VALUE)                    \
  117.   (isinf ((VALUE))                            \
  118.    ? fprintf (FILE, "\t.single 0r%s99e999\n", ((VALUE) > 0 ? "" : "-")) \
  119.    : fprintf (FILE, "\t.single 0r%.20e\n", (VALUE)))
  120.  
  121. #undef ASM_OUTPUT_FLOAT_OPERAND
  122. #define ASM_OUTPUT_FLOAT_OPERAND(FILE,VALUE)                \
  123.   (isinf ((VALUE))                            \
  124.    ? fprintf (FILE, "#0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
  125.    : fprintf (FILE, "#0r%.9g", (VALUE)))
  126.  
  127. #undef ASM_OUTPUT_DOUBLE_OPERAND
  128. #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE)                \
  129.   (isinf ((VALUE))                            \
  130.    ? fprintf (FILE, "#0r%s99e999", ((VALUE) > 0 ? "" : "-")) \
  131.    : fprintf (FILE, "#0r%.20g", (VALUE)))
  132.  
  133. /* use A5 as framepointer instead of A6, this makes A6 available as a
  134.  * general purpose register, and can thus be used without problems in
  135.  * direct library calls. */
  136. #undef FRAME_POINTER_REGNUM
  137. #define FRAME_POINTER_REGNUM 13
  138. #undef ARG_POINTER_REGNUM
  139. #define ARG_POINTER_REGNUM 13
  140.  
  141.  
  142. #define CC_INCLUDE_DIR    "gcc:include"
  143.  
  144.  
  145. #undef  FUNCTION_PROLOGUE
  146. #define FUNCTION_PROLOGUE(FILE, SIZE)     \
  147. { register int regno;                        \
  148.   register int mask = 0;                    \
  149.   extern char call_used_regs[];                    \
  150.   int fsize = ((SIZE) + 3) & -4;                \
  151.   if (frame_pointer_needed)                    \
  152.     { if (TARGET_68020 || fsize < 0x8000)            \
  153.         fprintf (FILE, "\tlink a5,#%d\n", -fsize);        \
  154.       else                            \
  155.     fprintf (FILE, "\tlink a5,#0\n\tsubl #%d,sp\n", fsize); }  \
  156.   for (regno = 24; regno < 56; regno++)                \
  157.     if (regs_ever_live[regno] && ! call_used_regs[regno])    \
  158.       fprintf(FILE, "\tfpmoved %s, sp@-\n",            \
  159.           reg_names[regno]);                \
  160.   for (regno = 16; regno < 24; regno++)                \
  161.     if (regs_ever_live[regno] && ! call_used_regs[regno])    \
  162.        mask |= 1 << (regno - 16);                \
  163.   if ((mask & 0xff) != 0)                    \
  164.     fprintf (FILE, "\tfmovem #0x%x,sp@-\n", mask & 0xff);       \
  165.   mask = 0;                            \
  166.   for (regno = 0; regno < 16; regno++)                \
  167.     if (regs_ever_live[regno] && ! call_used_regs[regno])    \
  168.        mask |= 1 << (15 - regno);                \
  169.   if (frame_pointer_needed)                    \
  170.     mask &= ~ (1 << (15-FRAME_POINTER_REGNUM));            \
  171.   if (exact_log2 (mask) >= 0)                    \
  172.     fprintf (FILE, "\tmovel %s,sp@-\n", reg_names[15 - exact_log2 (mask)]);  \
  173.   else if (mask) fprintf (FILE, "\tmoveml #0x%x,sp@-\n", mask); }
  174.  
  175.  
  176. #undef  FUNCTION_EPILOGUE
  177. #define FUNCTION_EPILOGUE(FILE, SIZE) \
  178. { register int regno;                        \
  179.   register int mask, fmask;                    \
  180.   register int nregs;                        \
  181.   int offset, foffset, fpoffset;                \
  182.   extern char call_used_regs[];                    \
  183.   extern int current_function_pops_args;            \
  184.   extern int current_function_args_size;            \
  185.   int fsize = ((SIZE) + 3) & -4;                \
  186.   int big = 0;                            \
  187.   FUNCTION_EXTRA_EPILOGUE (FILE, SIZE);                \
  188.   nregs = 0;  fmask = 0; fpoffset = 0;                \
  189.   for (regno = 24 ; regno < 56 ; regno++)            \
  190.     if (regs_ever_live[regno] && ! call_used_regs[regno])    \
  191.       nregs++;                            \
  192.   fpoffset = nregs*8;                        \
  193.   nregs = 0;                            \
  194.   for (regno = 16; regno < 24; regno++)                \
  195.     if (regs_ever_live[regno] && ! call_used_regs[regno])    \
  196.       { nregs++; fmask |= 1 << (23 - regno); }            \
  197.   foffset = fpoffset + nregs * 12;                \
  198.   nregs = 0;  mask = 0;                        \
  199.   if (frame_pointer_needed) regs_ever_live[FRAME_POINTER_REGNUM] = 0; \
  200.   for (regno = 0; regno < 16; regno++)                \
  201.     if (regs_ever_live[regno] && ! call_used_regs[regno])    \
  202.       { nregs++; mask |= 1 << regno; }                \
  203.   offset = foffset + nregs * 4;                    \
  204.   if (offset + fsize >= 0x8000                     \
  205.       && frame_pointer_needed                     \
  206.       && (mask || fmask || fpoffset))                 \
  207.     { fprintf (FILE, "\tmovel #%d,a0\n", -fsize);        \
  208.       fsize = 0, big = 1; }                    \
  209.   if (exact_log2 (mask) >= 0) {                    \
  210.     if (big)                            \
  211.       fprintf (FILE, "\tmovel a5@(-%d,a0:l),%s\n",        \
  212.            offset + fsize, reg_names[exact_log2 (mask)]);    \
  213.     else if (! frame_pointer_needed)                \
  214.       fprintf (FILE, "\tmovel sp@+,%s\n",            \
  215.            reg_names[exact_log2 (mask)]);            \
  216.     else                            \
  217.       fprintf (FILE, "\tmovel a5@(-%d),%s\n",            \
  218.            offset + fsize, reg_names[exact_log2 (mask)]); }    \
  219.   else if (mask) {                        \
  220.     if (big)                            \
  221.       fprintf (FILE, "\tmoveml a5@(-%d,a0:l),#0x%x\n",        \
  222.            offset + fsize, mask);                \
  223.     else if (! frame_pointer_needed)                \
  224.       fprintf (FILE, "\tmoveml sp@+,#0x%x\n", mask);        \
  225.     else                            \
  226.       fprintf (FILE, "\tmoveml a5@(-%d),#0x%x\n",        \
  227.            offset + fsize, mask); }                \
  228.   if (fmask) {                            \
  229.     if (big)                            \
  230.       fprintf (FILE, "\tfmovem a5@(-%d,a0:l),#0x%x\n",        \
  231.            foffset + fsize, fmask);                \
  232.     else if (! frame_pointer_needed)                \
  233.       fprintf (FILE, "\tfmovem sp@+,#0x%x\n", fmask);        \
  234.     else                            \
  235.       fprintf (FILE, "\tfmovem a5@(-%d),#0x%x\n",        \
  236.            foffset + fsize, fmask); }            \
  237.   if (fpoffset != 0)                        \
  238.     for (regno = 55; regno >= 24; regno--)            \
  239.       if (regs_ever_live[regno] && ! call_used_regs[regno]) {    \
  240.     if (big)                        \
  241.       fprintf(FILE, "\tfpmoved a5@(-%d,a0:l), %s\n",    \
  242.           fpoffset + fsize, reg_names[regno]);        \
  243.     else if (! frame_pointer_needed)            \
  244.       fprintf(FILE, "\tfpmoved sp@+, %s\n",            \
  245.           reg_names[regno]);                \
  246.     else                            \
  247.       fprintf(FILE, "\tfpmoved a5@(-%d), %s\n",        \
  248.           fpoffset + fsize, reg_names[regno]);        \
  249.     fpoffset -= 8;                        \
  250.       }                                \
  251.   if (frame_pointer_needed)                    \
  252.     fprintf (FILE, "\tunlk a5\n");                \
  253.   if (current_function_pops_args && current_function_args_size)    \
  254.     fprintf (FILE, "\trtd #%d\n", current_function_args_size);    \
  255.   else fprintf (FILE, "\trts\n"); }
  256.  
  257.